//
//  ScratchProtocol.h
//  EsotericDemo
//
//  Created by Temp Admin on 6/12/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ScratchMessage.h"
#import "ScratchEvents.h"

//Flags...
#define PS_INTERNAL 0x0001
#define PS_ENCRYPTED 0x0002
#define PS_COMPRESSED 0x0004

//Internal primary commands...
#define PS_CONFIG 1
#define PS_PINGPONG 10
//PS_CONFIG secondary commands...
#define PS_CONFIRM 1
//PS_PINGPONG secondary commands...
#define PS_PING 1
#define PS_PONG 2

@interface ScratchClient : NSObject <ScratchCore, NSStreamDelegate>
{
@private
	//Streams and session information
	NSInputStream *inputStream;
	NSOutputStream *outputStream;
	ScratchEvents *events;
	
	//State information for data
	NSMutableData *incoming, *outgoing;
	bool payload, spaceOpen;
	int currentRemaining;
	
	//Other info
	uint32_t SessionID;
}

@property (nonatomic) int32_t key;
@property uint8_t vMajor;
@property uint8_t vMinor;
@property bool useSessionIds;
@property int port;
@property bool writeLock;

- (id) initWithInfo : (ScratchEvents *) setEvents;
- (void) connect : (CFStringRef) ip;

@end
